/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Anthares
 */
@Entity
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Promotions.findAll", query = "SELECT p FROM Promotions p"),
    @NamedQuery(name = "Promotions.findByPromoId", query = "SELECT p FROM Promotions p WHERE p.promoId = :promoId"),
    @NamedQuery(name = "Promotions.findByDateDeb", query = "SELECT p FROM Promotions p WHERE p.dateDeb = :dateDeb"),
    @NamedQuery(name = "Promotions.findByDateFin", query = "SELECT p FROM Promotions p WHERE p.dateFin = :dateFin"),
    @NamedQuery(name = "Promotions.findByPourcentage", query = "SELECT p FROM Promotions p WHERE p.pourcentage = :pourcentage")})
public class Promotions implements Serializable {
    @Basic(optional = false)
    @NotNull
    @Column(name = "POURCENTAGE", nullable=false)
    private double pourcentage;
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "PROMO_ID", nullable = false)
    private Integer promoId;

    @Basic(optional = false)
    @NotNull
    @Column(name = "DATE_DEB", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date dateDeb;

    @Basic(optional = false)
    @NotNull
    @Column(name = "DATE_FIN", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date dateFin;


    @ManyToMany(mappedBy = "promotionsList")
    private List<CategProd> categProdList;

    @ManyToMany(mappedBy = "promotionsList")
    private List<Produit> produitList;

    public Promotions() {
    }

    public Promotions(Integer promoId) {
        this.promoId = promoId;
    }

    public Promotions(Integer promoId, Date dateDeb, Date dateFin, double pourcentage) {
        this.promoId = promoId;
        this.dateDeb = dateDeb;
        this.dateFin = dateFin;
        this.pourcentage = pourcentage;
    }

    public Integer getPromoId() {
        return promoId;
    }

    public void setPromoId(Integer promoId) {
        this.promoId = promoId;
    }

    public Date getDateDeb() {
        return dateDeb;
    }

    public void setDateDeb(Date dateDeb) {
        this.dateDeb = dateDeb;
    }

    public Date getDateFin() {
        return dateFin;
    }

    public void setDateFin(Date dateFin) {
        this.dateFin = dateFin;
    }

    public double getPourcentage() {
        return pourcentage;
    }

    public void setPourcentage(double pourcentage) {
        this.pourcentage = pourcentage;
    }

    @XmlTransient
    public List<CategProd> getCategProdList() {
        return categProdList;
    }

    public void setCategProdList(List<CategProd> categProdList) {
        this.categProdList = categProdList;
    }

    @XmlTransient
    public List<Produit> getProduitList() {
        return produitList;
    }

    public void setProduitList(List<Produit> produitList) {
        this.produitList = produitList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (promoId != null ? promoId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Promotions)) {
            return false;
        }
        Promotions other = (Promotions) object;
        if ((this.promoId == null && other.promoId != null) || (this.promoId != null && !this.promoId.equals(other.promoId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Model.Promotions[ promoId=" + promoId + " ]";
    }
    
}
